/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Services;

import Services.exception.ServiceException;
import Services.exception.UnableToConnectException;
import beans.ProductBean;
import database.daos.ProductDAO;



/**
 *
 * @author Anthar
 */
public class ProductServices {

    private ProductDAO productDAO;

   public ProductServices(){
        productDAO = new ProductDAO();
   }

   public ProductBean searchProduct(int idProduct) throws UnableToConnectException {
        try {
            return getProductDAO().searchProduct(idProduct);
        } catch (database.daos.DAOException ex) {
            throw new UnableToConnectException(ex.getExceptionMessage());
        }

       
    }

   public boolean deleteProduct(int idProduct) throws ServiceException{
        try {
            getProductDAO().deleteProduct(idProduct);
            return true;
        } catch (database.daos.DAOException ex) {
            throw new UnableToConnectException(ex.getExceptionMessage());
        }

    }

   /*******************
    * GETERS Y SETTERS
    *******************/

    /**
     * @return the productDAO
     */
    public ProductDAO getProductDAO() {
        return productDAO;
    }

    /**
     * @param productDAO the productDAO to set
     */
    public void setProductDAO(ProductDAO productDAO) {
        this.productDAO = productDAO;
    }
   

}
